[NET] Enable TCPv4 segmentation offload in front/back drivers.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 1 Aug 2006 10:54:45 +0000 (11:54 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 1 Aug 2006 10:54:45 +0000 (11:54 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c

index 82832368b9b52e4c4f86ba9fd9a41535bfaaff27..4de5a9cb0b6a65d89efab0a99be91543e1fbaacf 100644 (file)
@@ -221,13 +221,20 @@ static struct sk_buff *netbk_copy_skb(struct sk_buff *skb)
        return NULL;
 }
 
+static inline int netbk_max_required_rx_slots(netif_t *netif)
+{
+       if (netif->features & (NETIF_F_SG|NETIF_F_TSO))
+               return MAX_SKB_FRAGS + 2; /* header + extra_info + frags */
+       return 1; /* all in one */
+}
+
 static inline int netbk_queue_full(netif_t *netif)
 {
-       RING_IDX peek = netif->rx_req_cons_peek;
+       RING_IDX peek   = netif->rx_req_cons_peek;
+       RING_IDX needed = netbk_max_required_rx_slots(netif);
 
-       return ((netif->rx.sring->req_prod - peek) <= (MAX_SKB_FRAGS + 1)) ||
-              ((netif->rx.rsp_prod_pvt + NET_RX_RING_SIZE - peek) <=
-               (MAX_SKB_FRAGS + 1));
+       return ((netif->rx.sring->req_prod - peek) < needed) ||
+              ((netif->rx.rsp_prod_pvt + NET_RX_RING_SIZE - peek) < needed);
 }
 
 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -271,7 +278,7 @@ int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (netbk_can_queue(dev) && netbk_queue_full(netif)) {
                netif->rx.sring->req_event = netif->rx_req_cons_peek +
-                       MAX_SKB_FRAGS + 2;
+                       netbk_max_required_rx_slots(netif);
                mb(); /* request notification /then/ check & stop the queue */
                if (netbk_queue_full(netif))
                        netif_stop_queue(dev);
index eb51533942b9cc396827750fa524e3080caae911..0d34bc85112a611863860ef9bbfa90677fe812f6 100644 (file)
@@ -101,14 +101,12 @@ static int netback_probe(struct xenbus_device *dev,
                        goto abort_transaction;
                }
 
-#if 0 /* KAF: After the protocol is finalised. */
                err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4",
                                    "%d", 1);
                if (err) {
                        message = "writing feature-gso-tcpv4";
                        goto abort_transaction;
                }
-#endif
 
                err = xenbus_transaction_end(xbt, 0);
        } while (err == -EAGAIN);
@@ -384,7 +382,6 @@ static int connect_rings(struct backend_info *be)
                be->netif->dev->features |= NETIF_F_SG;
        }
 
-#if 0 /* KAF: After the protocol is finalised. */
        if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4", "%d",
                         &val) < 0)
                val = 0;
@@ -392,7 +389,6 @@ static int connect_rings(struct backend_info *be)
                be->netif->features |= NETIF_F_TSO;
                be->netif->dev->features |= NETIF_F_TSO;
        }
-#endif
 
        /* Map the shared frame, irq etc. */
        err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn);
index 9ab89571de8698be41a674bdb9d311bc392d9e91..3be2e87a7c5e04efd2bf621ff1df6b47dac87c8f 100644 (file)
@@ -338,13 +338,11 @@ again:
                goto abort_transaction;
        }
 
-#if 0 /* KAF: After the protocol is finalised. */
        err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1);
        if (err) {
                message = "writing feature-gso-tcpv4";
                goto abort_transaction;
        }
-#endif
 
        err = xenbus_transaction_end(xbt, 0);
        if (err) {
@@ -1327,9 +1325,7 @@ static int xennet_set_tso(struct net_device *dev, u32 data)
                if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
                                 "feature-gso-tcpv4", "%d", &val) < 0)
                        val = 0;
-#if 0 /* KAF: After the protocol is finalised. */
                if (!val)
-#endif
                        return -ENOSYS;
        }